<template>
  <view class="container">
    <view class="list">
      <view class="list-item" v-for="(item, index) in dataLits" :key="item.id">
        <view class="left-image" style="width: 25%">
          <span style="font-size: 32rpx">¥</span>
          <span style="font-size: 49rpx; margin-left: 12rpx">{{
            item.reduceMoney || item.discountMoney
          }}</span>
        </view>
        <view class="right" v-if="item.couponType == 1" style="width: 50%">
          <view class="title"
            >满{{ item.satisfyMoney }}减{{ item.reduceMoney }}</view
          >
          <view class="date">领取后{{ item.validDays }}天有效</view>
          <view class="date">使用范围：不限</view>
        </view>
        <view class="right" v-else style="width: 50%">
          <view class="title">无门槛劵</view>
          <view class="date">领取后{{ item.validDays }}有效</view>
          <view class="date">使用范围：不限</view>
        </view>
        <view style="width: 35%"></view>
      </view>
    </view>
    <uv-empty
      v-if="dataLits.length <= 0"
      mode="message"
      text="暂无优惠劵"
      textColor="#000"
      icon="http://jy-nfc.oss-cn-hangzhou.aliyuncs.com/2025/01/24/cf3aa70933d942a7a7a71ea378bb4c50.png"
    ></uv-empty>
    <view class="button-fb" @click="newCoupon">创建优惠劵</view>
  </view>
</template>

<script>
import { getCouponList } from "@/common/api.js";

const app = getApp();
export default {
  data() {
    return {
      dataLits: [],
    };
  },

  onLoad() {
    this.getDate();
  },
  methods: {
    newCoupon() {
      app.navigationTo("page_account/coupon/new");
    },
    getDate() {
      return new Promise((resolve, reject) => {
        getCouponList()
          .then((res) => {
            console.log(res);
            this.dataLits = res.rows;
            this.loading = false;
            resolve();
          })
          .catch((err) => {
            this.loading = false;
            console.log("userInfoerr", err);
          });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  overflow: hidden;
  min-height: 100vh;
  width: 100vw;
  padding: 22rpx;
  padding-bottom: calc(96rpx + 32rpx + 22rpx);
  box-sizing: border-box;
  background: #f7f8fa;

  .button-fb {
    position: fixed;
    bottom: 32rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 480rpx;
    height: 96rpx;
    background: linear-gradient(180deg, #886ae6 0%, #4635ff 99%);
    border-radius: 48rpx;
    font-weight: 400;
    font-size: 32rpx;
    color: #ffffff;
    line-height: 96rpx;
    text-align: center;
  }

  .list {
    // padding: 32rpx 24rpx;
    // box-sizing: border-box;

    .list-item {
      padding: 24rpx 40rpx;
      box-sizing: border-box;
      border-radius: 20rpx;
      background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.62) 64%,
        #ffffff 100%
      );
      box-shadow: 0rpx 0rpx 40rpx 0rpx rgba(0, 0, 0, 0.04);
      border: 2rpx solid #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 24rpx;

      .left-image {
        border-radius: 12rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ff4e04;
        font-weight: 900;
      }

      .right {
        .title {
          font-weight: 700;
          font-size: 36rpx;
          color: #000000;
          line-height: 36rpx;
          margin-bottom: 16rpx;
        }

        .date {
          font-weight: 400;
          font-size: 28rpx;
          color: #86909c;
          line-height: 40rpx;
        }
      }
    }
  }
}
</style>
